package com.qianyu.project.mapper.provider.smj;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface smjLaberApplyDao {
    //添加劳务付款
    @Insert("insert into apply_labor_payment( id,apply_date, payment_name, type, ctr_id, p_id, company_id, contract_amount, penalty, withhold, settle_type, bank_id, agree_amount, handler_id, agree_upper, attach_ids, settle_comment) " +
            "value(#{id}, #{apply_date},#{payment_name},#{type},#{ctr_id},#{p_id},#{company_id},#{contract_amount},#{penalty},#{withhold},#{settle_type},#{bank_id},#{agree_amount},#{handler_id},#{agree_upper},#{attach_ids},#{settle_comment})")
    void AddLaberApply(String id, String apply_date, String payment_name, String type, String ctr_id, String p_id, String company_id, String contract_amount, String penalty, String withhold, String settle_type, String bank_id, String agree_amount, String handler_id, String agree_upper, String attach_ids, String settle_comment);

    //修改审批状态
    @Update("update apply_labor_payment set approve_status=#{approve_status} where id=#{id}")
    void UpdateApproveStatus(int approve_status, String id);


    //查看劳务付款列表
    @SelectProvider(type = smjLaberApplyProvider.class ,method="listLaberApply")
    IPage<Map<String, Object>> listLaberApply(IPage<Map<String, Object>> page, Map<String, String> params);

    //获取流程id
    @Select("select fid from form  where id=#{id} and target ='apply_labor_payment'")
    String getFid(String id);

    //获取审批流程
    @Select("select fa.*,fn.flowNodeName,su.user_realname from form_audit fa ,flow_node fn ,system_user su where fa.fid=#{fid} and fa.flowNodeId = fn.flowNodeId and fa.eid=su.id")
    List<Map<String, Object>> getfromaudit(String fid);
}
